package com.zh.core.controller;

import com.zh.core.entity.Customer;
import com.zh.core.service.CustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by zhaohui on 2019/8/11
 * Description:
 */
@Controller
@RequestMapping("/lar")
public class CustomerController {

    @Autowired
    CustomerService customerService;

    /**
     * 获取所有客户信息
     *
     * @return
     */
    @RequestMapping(value = "/getAllCustomer")
    @ResponseBody
    public List<Customer> getAllCustomer() {
        return customerService.queryAllCustomer();
    }

    /**
     * 分页获取所有客户信息
     * @param offset
     * @param limit
     * @return
     */
    @RequestMapping(value = "/getCustomerWithPage")
    @ResponseBody
    public Map<String, Object> getCustomerWithPage(int offset, int limit) {
        return customerService.queryCustomerWithPage(offset, limit);
    }

    /**
     * 客户信息列表页面
     *
     * @return
     */
    @RequestMapping("/customerList")
    public String customerList() {
        return "customerList";
    }

    /**
     * 客户信息列表页面2
     *
     * @return
     */
    @RequestMapping("/customerList2")
    public String customerList2() {
        return "customerList2";
    }

}
